<template>
  <div class="about">
    <span>关于页面</span>
    <router-link to="/about/ni">你说的吧</router-link>
    <router-link to="/about/ta">她知道么</router-link>
    <keep-alive>
      <router-view></router-view>
    </keep-alive>
  </div>
</template>
<script>
export default {
  name: "About",
  data(){
    return{
      message: "好的内",
      path: "/about/ni"
    };
  },
  created(){},
  destroyed(){},
  activated(){ //当页面处于活跃状态的时候，把页面的中的path值赋给它，从而实现页面的跳转
    this.$router.push(this.path);
  },
  deactivated(){},
  beforeRouteLeave(to,from,next){ //离开页面的时候记录当前页面的路由,注意获取当前路由时this.$route.path
    this.path= this.$route.path;
    next();
  }
}
/* 
  activated和deactivated只有这两个组件被保存了状态为keep-alive时，才是有效的
*/
</script>